package cn.tedu._05mvcboot01.controller;

import cn.tedu._05mvcboot01.pojo.dto.WeiChatDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {
    @RequestMapping(value = "/v1/users/login")
    @ResponseBody
    public String login(){
        return "恭喜你，登录成功";
    }

    @RequestMapping(value = "/v1/users/reg")
    @ResponseBody
    public String reg(HttpServletRequest request){
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        return username + "," + password;
    }

    //http://localhost:8080/v1/users/changepwd?username=xxx&newpwd=yyy

    @RequestMapping(value = "/v1/users/changepwd")
    @ResponseBody
    public String changepwd(String username,String newpwd){
        return username + "-" + newpwd;
    }

    //http://localhost:8080/v1/users/weiChat?name=微信号&pwd=密码

    @RequestMapping(value = "/v1/users/weiChat")
    @ResponseBody
    public String weiChat(WeiChatDTO weiChatDTO){
        String name = weiChatDTO.getName();
        String pwd = weiChatDTO.getPwd();
        return name + "," + pwd;
    }



}
